﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;
using System.Windows.Media;

using NUnitResults;

namespace NUnitResultsExplorer
{
    [ValueConversion(typeof(Status), typeof(Brush))]
    public class StatusToBrushConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            var brushes = new Dictionary<Status, Brush>
            {
                { Status.Error, new SolidColorBrush(Color.FromArgb(192, 192, 0, 0)) },
                { Status.Failed, new SolidColorBrush(Color.FromArgb(192, 192, 0, 0)) },
                { Status.Ignored, new SolidColorBrush(Color.FromArgb(192, 255, 192, 0)) },
                { Status.Inconclusive, new SolidColorBrush(Color.FromArgb(192, 192, 0, 192)) },
                { Status.NonRunnable, new SolidColorBrush(Color.FromArgb(192, 192, 0, 192)) },
                { Status.Success, new SolidColorBrush(Color.FromArgb(192, 0, 192, 0)) },
                { Status.Unrecognised, new SolidColorBrush(Color.FromArgb(192, 0, 0, 0)) }
            };

            try
            {
                Status s = (Status)value;
                return brushes[s];
            }
            catch
            {
                return Brushes.OrangeRed;
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
